package com.mybatiscore.jiaocheng.d05mybatis_高级映射_加载延迟;

import com.mybatiscore.Mapper.TStudentMapper;
import com.mybatiscore.POJO.TStudent;
import com.mybatiscore.Util.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

public class d01_多对一 {
    //1.级联属性映射

    //2.association
    @Test
    public void test2(){
        SqlSession sqlSession = SqlSessionUtil.openSession();
        TStudentMapper mapper = sqlSession.getMapper(TStudentMapper.class);
        TStudent student = mapper.selectById1(1);
        System.out.println(student.toString());
        sqlSession.close();
    }

    //3.分步_加载延迟
    @Test
    public void test3(){
        SqlSession sqlSession = SqlSessionUtil.openSession();
        TStudentMapper mapper = sqlSession.getMapper(TStudentMapper.class);
        TStudent student = mapper.selectById2(5);
        //分布
        System.out.println(student.toString());
        //加载延迟
//        System.out.println(student.getSname());
        sqlSession.close();
    }

}
